<template>
  <view
    class="walletBox"
    :style="[outModuleCss]"
    v-if="propsData.params.showModule"
  >
    <view :style="[moduleBgCss]" class="module-bg"></view>
    <view class="walletContent">
      <view
        class="title"
        v-if="propsData.params.useTitle == 1"
        @click="$utils.toUrl('/user/balance/balance')"
      >
        <moduleHeader
          :propsData="propsData"
          :moreText="$t('diy.wallet')"
          :moduleName="propsData.params.text"
        ></moduleHeader>
      </view>
      <view class="walletList">
        <template v-for="item in propsData.params.list">
          <view class="walletItem" @click.stop="chooseItem(item)">
            <view class="count">{{ getNum(item) }}</view>

            <text class="name" :style="[{ color: item.color }]">{{
              item.name
            }}</text>
            <text class="sub" :style="[{ color: item.subColor }]">{{
              item.subName
            }}</text>
          </view>
        </template>
      </view>
    </view>
  </view>
</template>

<script>
import { diySysPageMixin } from "../../mixins/index";
import moduleHeader from "@/components/diyNew/components/moduleHeader/index.vue";
export default {
  name: "userWallet",
  props: {
    propsData: {
      type: Object,
      default: {}
    },
    myInfo: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  mixins: [diySysPageMixin],
  components: {
    moduleHeader
  },
  computed: {
    getNum() {
      return (item) => {
        let num = "",
          { myInfo } = this;

        if (!myInfo) return 0;

        switch (item.walletItemType) {
          case "walletIntegral":
            num = myInfo.user_info?.integral || 0;
            break;

          case "walletBalance":
            num = myInfo.user_info?.money || 0;
            break;

          case "walletLeaguePrice":
            num = myInfo.user_info?.league_price || 0;
            break;

          default:
            break;
        }
        return parseInt(num);
      };
    }
  },
  data() {
    return {};
  },

  methods: {
    chooseItem(item) {
      let url = "";

      switch (item.walletItemType) {
        case "walletIntegral":
          url = "/user/balance/balance-tab?type=2";
          break;

        case "walletBalance":
          url = "/user/balance/balance-tab?type=1";
          break;

        case "walletLeaguePrice":
          url = "/user/new_balance/new_balance";
          break;

        default:
          break;
      }

      this.$utils.toUrl(url);
    }
  }
};
</script>

<style lang="scss" scoped>
.walletBox {
  width: 100%;
  position: relative;
  .module-bg {
    width: 100%;
    height: 100%;
    z-index: -1;
    position: absolute;
    left: 0;
    top: 0;
  }
  .walletContent {
    width: 100%;
    padding: 24rpx;
    .title {
      padding-bottom: 24rpx;
      border-bottom: 1px solid #f1f1f1;
    }
    .walletList {
      display: flex;
      align-items: center;
      padding: 16rpx 16rpx 0 16rpx;
      justify-content: space-between;
      .walletItem {
        display: flex;
        flex-direction: column;
        position: relative;
        align-items: center;
        flex: 1;
        .count {
          display: flex;
          align-items: baseline;
          font-size: 36rpx;
          font-weight: 600;
          font-family: PingFang SC;
          margin-bottom: 10rpx;
          text:nth-child(2) {
            font-size: 36rpx;
            font-weight: 400;
          }
        }
        .name {
          font-size: 24rpx;
          font-family: PingFang SC;
        }
        .sub {
          font-size: 20rpx;
        }
      }
    }
  }
}
</style>
